home *** CD-ROM | disk | FTP | other *** search
/ Geek Games #12 / GEGA012.iso / Jogos de Azar / fruit.swf / scripts / C_TablePrizeCLASS.as < prev    next >
Text File  |  2006-01-17  |  5KB  |  215 lines

  1. _global.C_TablePrizeCLASS = function()
  2. {
  3. };
  4. C_TablePrizeCLASS.prototype = new MovieClip();
  5. C_TablePrizeCLASS.prototype.onLoad = function()
  6. {
  7.    this.stop();
  8.    var b;
  9.    var i = 1;
  10.    while(i <= this.max)
  11.    {
  12.       b = this.colimns_mc["c" + i + "_btn"];
  13.       b.n = i;
  14.       b.onPress = function()
  15.       {
  16.          this._parent._parent.setCoins(this.n);
  17.          this._parent._parent.doOut();
  18.       };
  19.       b.onRollOver = function()
  20.       {
  21.          var o = this._parent._parent;
  22.          var h = o.hints[this.n];
  23.          o.doOver();
  24.          if(h != undefined)
  25.          {
  26.             o.showAlt(h);
  27.          }
  28.       };
  29.       b.onDragOut = b.onRollOut = function()
  30.       {
  31.          this._parent._parent.doOut();
  32.          this._parent._parent.hideAlt();
  33.       };
  34.       i++;
  35.    }
  36.    this.setTextColors(this.selecText_color == undefined ? 16777215 : this.selecText_color,this.unselText_color == undefined ? 0 : this.unselText_color,this.topPrizeText_color == undefined ? 14221312 : this.topPrizeText_color);
  37.    var f = function(c)
  38.    {
  39.       var alph;
  40.       var o = this.owner;
  41.       var white = o.selecText_color;
  42.       var black = o.unselText_color;
  43.       var top = o.topPrizeText_color;
  44.       if(c == "white")
  45.       {
  46.          if(this.topPrize)
  47.          {
  48.             c = top;
  49.             alph = 100;
  50.          }
  51.          else
  52.          {
  53.             c = white;
  54.             alph = 80;
  55.          }
  56.       }
  57.       else
  58.       {
  59.          c = black;
  60.          alph = 50;
  61.       }
  62.       tf = new TextFormat();
  63.       tf.color = c;
  64.       this.setTextFormat(tf);
  65.       this._alpha = alph;
  66.    };
  67.    var j = 1;
  68.    while(j <= this.max)
  69.    {
  70.       var i = 1;
  71.       while(i <= this.numLines)
  72.       {
  73.          o = this.numbers_mc["row_" + i + "_col_" + j + "_txt"];
  74.          o.setTextColor = f;
  75.          o.owner = this;
  76.          o.topPrize = i == this.numLines && j == this.max;
  77.          i++;
  78.       }
  79.       j++;
  80.    }
  81.    if(!this._coins)
  82.    {
  83.       this._coins = 1;
  84.    }
  85.    this.setCoins(this._coins);
  86.    var o = {};
  87.    o[1] = "Bet ONE coin";
  88.    o[2] = "Bet TWO coins";
  89.    o[3] = "Bet TREE coins";
  90.    o[4] = "Bet FOUR coins";
  91.    o[5] = "Bet FIVE coins";
  92.    this.setHints(o);
  93. };
  94. C_TablePrizeCLASS.prototype.setTablePrizes = function(table)
  95. {
  96.    if(!table)
  97.    {
  98.       return undefined;
  99.    }
  100.    var j = 1;
  101.    while(j <= this.max)
  102.    {
  103.       var i = 1;
  104.       while(i <= this.numLines)
  105.       {
  106.          this.numbers_mc["row_" + i + "_col_" + j + "_txt"].text = table["line_" + i].prize[j - 1];
  107.          this.numbersShadow_mc["row_" + i + "_col_" + j + "_txt"].text = table["line_" + i].prize[j - 1];
  108.          i++;
  109.       }
  110.       j++;
  111.    }
  112.    this.setCoins(this._coins);
  113. };
  114. C_TablePrizeCLASS.prototype.setHints = function(h)
  115. {
  116.    this.hints = h;
  117. };
  118. C_TablePrizeCLASS.prototype.setCoins = function(c)
  119. {
  120.    if(c < 0 || c > this.max)
  121.    {
  122.       return false;
  123.    }
  124.    this.colimns_mc.gotoAndStop("Coins_" + c);
  125.    delete this.colimns_mc["c" + this._coins + "_btn"].enabled;
  126.    this.colimns_mc["c" + c + "_btn"].enabled = false;
  127.    this._coins = c;
  128.    var o;
  129.    var color;
  130.    var j = 1;
  131.    while(j <= this.max)
  132.    {
  133.       cr = j != c ? "black" : "white";
  134.       var i = 1;
  135.       while(i <= this.numLines)
  136.       {
  137.          o = this.numbers_mc["row_" + i + "_col_" + j + "_txt"];
  138.          o.setTextColor(cr);
  139.          i++;
  140.       }
  141.       j++;
  142.    }
  143.    this.prizeHolder_mc.removeMovieClip();
  144.    this.client.client[this.client.handler](c,this);
  145. };
  146. C_TablePrizeCLASS.prototype.displayPrize = function(r)
  147. {
  148.    var j = 1;
  149.    while(j <= this.max)
  150.    {
  151.       var i = 1;
  152.       while(i <= this.numLines)
  153.       {
  154.          o = this.numbers_mc["row_" + i + "_col_" + j + "_txt"];
  155.          o.setTextColor("black");
  156.          i++;
  157.       }
  158.       j++;
  159.    }
  160.    if(!(r instanceof Array))
  161.    {
  162.       r = [r];
  163.    }
  164.    var a = [];
  165.    var i = 0;
  166.    while(i < r.length)
  167.    {
  168.       a.push(this.numbers_mc["row_" + r[i] + "_col_" + this._coins + "_txt"]);
  169.       i++;
  170.    }
  171.    this.prizeHolder_mc = this.createEmptyMovieClip("holder",123);
  172.    this.prizeHolder_mc.onEnterFrame = function()
  173.    {
  174.       var cr;
  175.       var i = 0;
  176.       while(i < a.length)
  177.       {
  178.          this.blink = !this.blink;
  179.          cr = !this.blink ? "black" : "white";
  180.          a[i].setTextColor(cr);
  181.          i++;
  182.       }
  183.       if(a.length % 2 == 0)
  184.       {
  185.          this.blink = !this.blink;
  186.       }
  187.    };
  188. };
  189. C_TablePrizeCLASS.prototype.setTextColors = function(selected, unselected, top)
  190. {
  191.    if(top != undefined)
  192.    {
  193.       this.topPrizeText_color = top;
  194.    }
  195.    if(selected != undefined)
  196.    {
  197.       this.selecText_color = selected;
  198.    }
  199.    if(unselected != undefined)
  200.    {
  201.       this.unselText_color = unselected;
  202.    }
  203. };
  204. C_TablePrizeCLASS.prototype.setChangeHandler = function(client, handler)
  205. {
  206.    this.client = {client:client,handler:handler};
  207. };
  208. C_TablePrizeCLASS.prototype.addProperty("coins",function()
  209. {
  210.    return this._coins;
  211. }
  212. ,C_TablePrizeCLASS.prototype.setCoins);
  213. ASSetPropFlags(_global,"C_TablePrizeCLASS",131);
  214. Object.registerClass("C_TablePrizeCLASS",C_TablePrizeCLASS);
  215.